﻿using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using QuickUIT.Controls;

namespace QuickUIT.Tests
{
    [TestClass]
    public class UIHyperlinkTests
    {
        private BaseState _baseState;

        [TestInitialize]
        public void TestSetup()
        {
            _baseState = new BaseState(TestUtilities.GetTestApplicationFileName(), "@Name='QuickUIT Test Application'");
            _baseState.Execute();
        }

        [TestMethod]
        public void ShouldOpen()
        {
            var window = new UIWindow("@Name='QuickUIT Test Application'");
            UIHyperlink link = window.UIText("@Name='Link'").UIHyperlink("@AutomationId='link1'");
            link.Open();
        }

        [TestMethod]
        public void ShouldGetValue()
        {
            var window = new UIWindow("@Name='QuickUIT Test Application'");
            UIHyperlink link = window.UIText("@Name='Link'").UIHyperlink();
            Assert.AreEqual(null, link.Value);
        }

        [TestMethod]
        public void ShouldGetAllHyperlinks()
        {
            var window = new UIWindow("@Name='QuickUIT Test Application'");
            List<UIHyperlink> hyperlinks = window.UIHyperlinks();
            Assert.AreEqual(1, hyperlinks.Count);
            Assert.AreEqual("Link", hyperlinks[0].Name);
        }

        [TestCleanup]
        public void TestTeardown()
        {
            _baseState.Cleanup();
        }
    }
}